#!/usr/bin/env bash

## 创建 etcd 配置
cat > /opt/etcd/cfg/etcd.conf << EOF
#[Member]
ETCD_NAME="${ETCD_CURRENT_NODE_HOSTNAME}"
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="https://${ETCD_CURRENT_NODE_IP}:2380"
ETCD_LISTEN_CLIENT_URLS="https://${ETCD_CURRENT_NODE_IP}:2379"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://${ETCD_CURRENT_NODE_IP}:2380"
ETCD_ADVERTISE_CLIENT_URLS="https://${ETCD_CURRENT_NODE_IP}:2379"
ETCD_INITIAL_CLUSTER="${ETCD_NODE1_HOSTNAME}=https://${ETCD_NODE1_IP}:2380,${ETCD_NODE2_HOSTNAME}=https://${ETCD_NODE2_IP}:2380,${ETCD_NODE3_HOSTNAME}=https://${ETCD_NODE3_IP}:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
EOF

